$(function () {
//声明变量
    var chart_datagrid = $("#chart_datagrid");

    chart_datagrid.datagrid({
        url:'/chart/query.do',
        fit:true,
        fitColumns:true,
        toolbar:'#chart_toolbar',
        pagination:true,
        rownumber:true,
        singleSelect:true,
        columns:[[
            {field:'id',checkbox:true},
            {field:'sn',title:'商品编码',width:80},
            {field:'name',title:'商品名称',width:80},
            {field:'totalNumber',title:'销售数量',width:80},
            {field:'totalAmount',title:'销售总金额',width:80},
            {field:'profit',title:'毛利',width:80},
            {field:'profitPoint',title:'毛利率',width:80}
        ]]
    });

    var rows=chart_datagrid.datagrid("getSelected");


    var methodObj = {
        query:function (){
            //获取查询条件
            var keyword =  $("#keyword").textbox('getValue');

            //通过datagrid 的 load方法传递参数
            chart_datagrid.datagrid('load',{
                keyword:keyword
            });
        }
    };

    //统一绑定事件:
    $("a[data-cmd]").click(function () {
        var methodname = $(this).data("cmd");
        //动态获取调用方法名字,调用方法;
        methodObj[methodname]();
    })
});
